package com.jsong.linuo.string;

import java.util.Scanner;

/**
 * @Author: 黎诺
 * @CreateTime: 2025-04-30
 * @Description: 判断字符内容
 */

public class String02 {
    public static void main(String[] args) {
        //1.定义两个字符串,表示注册过的用户名和密码
        String username = "root";
        String password = "123";
        //2.创建Scanner对象,键盘录入用户名和密码
        Scanner sc = new Scanner(System.in);
        for (int i = 0; i < 3 ; i++) {
            System.out.println("请输入您的用户名:");
            String name = sc.next();

            System.out.println("请输入您的密码:");
            String pwd = sc.next();

            //3.比较,如只输入用户名和密码跟已经注册过的用户名一样,就登陆成功
            if (name.equals(username)&&pwd.equals(password)){
                System.out.println("登录成功!");
                break;
            }else{

                if (i==2){
                    System.out.println("账号冻结");
                }else{
                    System.out.println("登陆失败!");
                }
            }
        }

    }

}

